Skip to content

build-aux: Fix incorrect HEVC vertical resolution on AMD VCN #11998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lexano-ivs
Copy link
Contributor

The HEVC VCN encoder in AMD GPUs will output the incorrect vertical resolution in some cases, most importantly 1920x1080 will result in 1920x1088. A workaround for this issue is available in AMF on Windows, however on Linux with VAAPI and Mesa, a different solution is required.

This PR adds 2 upstream FFmpeg commits that have already been merged in FFmpeg master to address the incorrect AMF vertical resolution problem, for the flatpak build.

Description

Please refer to 1, 2, and 3 for context. The patches are taken from 2.

AMD VCN uses a different surface alignment compared to other GPUs for encoding, which required an upstream fix in Mesa, libva, FFmpeg, and the VCN firmware.

This commit adds the FFmpeg patches to the flatpak build of OBS which is currently using FFmpeg version n7.1, however the patches were applied upstream after that release. libva API version 1.21 or higher is also required, which is satisfied by using KDE runtime 6.8.

Note that the fix is applicable to flatpak builds only. Standalone and Debian package builds depend on the host library versions and will still have the problem until a version of FFmpeg with the fix is used.

Motivation and Context

The incorrect 1920x1088 HEVC output resolution (instead of 1920x1080) resulted in streaming disconnects for Twitch Enhanced Broadcasting Linux users. Local file recording when using AMD VAAPI HEVC also outputs 1088 instead of 1080. This commit fixes both cases.

How Has This Been Tested?

An earlier variant of the patch was tested in the TEB Beta community while Twitch was testing HEVC for 1920x1080p. I have also tested the patches on a local Linux development host and confirmed the output resolution by playing back the stream on Windows and inspecting the bitstream after a capture.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

AMD VCN uses a different surface alignment compared to other GPUs for
encoding, which required an upstream fix in Mesa, libva, FFmpeg, and
the VCN firmware.

This commit adds the FFmpeg patches to the flatpak build of OBS which
is currently using FFmpeg version n7.1, however the patches were applied
upstream after that release. libva API version 1.21 or higher is also
required, which is satisfied by using KDE runtime 6.8.

The incorrect 1920x1088 HEVC output resolution (instead of 1920x1080)
resulted in streaming disconnects for Twitch Enhanced Broadcsating
Linux users. Local file recording when using AMD VAAPI HEVC also
outputs 1088 instead of 1080. This commit fixes both cases.

Please refer to [1], [2], and [3] for context. The patches are taken
from [2].

Note that the fix is applicable to flatpak builds only. Standalone and
Debian package builds depend on the host library versions and will
still have the problem until a version of FFmpeg with the fix is used.

[1]: https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11222
[2]: https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=13168
[3]: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10985
@lexano-ivs lexano-ivs force-pushed the lexano/amd-vertical-fix branch from 2a936e0 to b6f7d90 Compare March 25, 2025 15:30
@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Apr 6, 2025
Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine since these patches are merged.

For reference:

@RytoEX RytoEX added this to the OBS Studio 31.1 milestone Apr 25, 2025
@RytoEX RytoEX merged commit 4efc6bf into obsproject:master Apr 25, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants